package com.yidu.KuangJia.mapper;

import com.yidu.KuangJia.entity.Righty;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public interface RightMapper {
    @Select("SELECT rh.rightCode,rh.rightName FROM USER u\n" +
            "JOIN\n" +
            "role r ON r.roleId=u.roleId\n" +
            "JOIN\n" +
            "rightandrole rar ON rar.roleId=r.roleId\n" +
            "JOIN\n" +
            "righty rh ON rh.rightCode=rar.rightCode\n" +
            "WHERE rh.rightParentCode='ROOT_MENU'")
    public List<Righty> selectRighty();

    @Select("SELECT rh.* FROM USER u\n" +
            "JOIN\n" +
            "role r ON r.roleId=u.roleId\n" +
            "JOIN\n" +
            "rightandrole rar ON rar.roleId=r.roleId\n" +
            "JOIN\n" +
            "righty rh ON rh.rightCode=rar.rightCode\n" +
            "WHERE u.userName=#{userName}AND u.userPwd=#{userPwd} AND rh.rightParentCode=#{rightCode} ")
    public List<Righty> selectRightyFu(Map map);

    @Select("SELECT * FROM righty WHERE rightParentCode=#{rightCode}")
    public List<Righty> selectRightyZi(String rightCode);
}
